import javax.swing.*;
import java.awt.*;

/**
 * Created by Scott Tiger.
 * User: tomaszsocha
 * Date: 2010-08-19
 * Time: 13:57:06
 */

public class ItemRenderer extends JLabel implements ListCellRenderer {
    public ItemRenderer() {
      setOpaque(true);
    }

    public Component getListCellRendererComponent(JList list, Object value,
        int index, boolean isSelected, boolean cellHasFocus) {
      if (value != null) {
        Item values = (Item) value;
        String setting = values.getPrefix() + " " + values.getName() + " "
            + values.getSufix();
        setText(setting);

      }
      setBackground(isSelected ? (getText().contains("Marynarka")?Color.BLACK : (getText().contains("Peleryna")?Color.RED :Color.BLUE)) : Color.WHITE);
      setForeground(isSelected ? Color.WHITE : getText().contains("Marynarka")?Color.BLACK : (getText().contains("Peleryna")?Color.RED :(getText().contains("Gorset")?Color.GREEN :Color.BLUE)));
      return this;
    }                                  
  }                                                                           